/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package carstore.userserver.services;

import carstore.userserver.models.UserInfo;
import java.util.List;

import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.query.Param;

/**
 *
 * @author wuhao
 */
public interface UserInfoRepository extends CrudRepository<UserInfo, Long> {
	@Override
	List<UserInfo> findAll();
	UserInfo findById(Integer Id);
	List<UserInfo> findByUserId(Integer Id);

	@Query(value ="select car.ID as id, car.FACTORY_ID as FactoryId, car.car_NAME as carNAME, car.car_SIZE as CarSIZE,user_info.selected as Selected from car, user_info where car.id=user_info.car_id and user_info.user_id=?1", nativeQuery = true)
	//@Query(value ="select car.* from car, user_info where car.id=user_info.car_id and user_info.user_id=?1", nativeQuery = true)
	List<Object[]> findCarsByUserId(Integer UserId);
}
